package neuroPoker.visualisation;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLayeredPane;

public class TablePan extends JLayeredPane implements ActionListener {

	private static final long serialVersionUID = 4848472767189030802L;

	private ImageComponent buttonComp = new ImageComponent(
			"/Images/button.png", 20, 11);

	public int[] butPosis = new int[] { 260, 80, 420, 80, 510, 100, 570, 190,
			510, 265, 420, 285, 260, 285, 185, 265, 105, 190, 185, 100 };

	public JButton pauseBut = new JButton("Pause");

	public static boolean paused = false;

	public TablePan() {
		this.setPreferredSize(new Dimension(680, 380));
		this.setSize(new Dimension(680, 380));
		this.setLocation(75, 15);
		this.setLayout(null);
		this.setOpaque(false);
		this.setVisible(true);
		this.add(new ImageComponent("/Images/tisch.png", 660, 370),
				new Integer(1));
		this.add(buttonComp, new Integer(2));
		pauseBut.setBounds(new Rectangle(0, 0, 75, 30));
		pauseBut.setLocation(605, 350);
		pauseBut.addActionListener(this);
		this.add(pauseBut, new Integer(2));
	}

	public void setButton(int buttPos) {
		buttonComp
				.setLocation(butPosis[buttPos * 2], butPosis[buttPos * 2 + 1]);
	}

	public void actionPerformed(ActionEvent ae) {
		if (ae.getSource().equals(pauseBut)) {
			paused = !paused;
			if (paused)
				pauseBut.setText("Weiter");
			else
				pauseBut.setText("Pause");
		}

	}

}
